#include "MephistoCAM.h"

void thorlabs_shutter_open( uint *gpio_reg, uint *gpio_in_reg ){
	
	setbit(*gpio_reg, BIT_SHUTTER);	// 低电位打开快门
	printf("[THORLABS_SHUTTER is opened]\n");
}

void thorlabs_shutter_close( uint *gpio_reg, uint *gpio_in_reg ){
	
	clrbit(*gpio_reg, BIT_SHUTTER);	//高电位关闭快门
	printf("[THORLABS_SHUTTER is closed]\n");
}


void thorlabs_shutter_exposure( uint *gpio_reg, 
								uint *gpio_in_reg,
								float exp_t_sec ){

	uint sleep_time_us = (uint)(exp_t_sec*1e6);
	
	printf("[THORLABS_SHUTTER] --> open for %g seconds.\n", exp_t_sec);

	thorlabs_shutter_open( gpio_reg, gpio_in_reg );

	usleep(sleep_time_us);

	thorlabs_shutter_close( gpio_reg, gpio_in_reg );
	
	printf("[THORLABS_SHUTTER] --> close.\n");
}

